package cn.com.service.impl;

import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import cn.com.beans.AccountInfo;
import cn.com.mapper.AccountInfoMapper;
import cn.com.service.AccountInfoService;

import java.util.List;

@Service
public class AccountInfoServiceImpl implements AccountInfoService{

    @Resource
    private AccountInfoMapper accountInfoMapper;

    @Override
    public boolean selectByPhone(String phone) {
        List<AccountInfo> accountInfo = accountInfoMapper.selectByPhone(phone);
        System.out.println("accountInfo = " + accountInfo);
        if(accountInfo.size() == 0) {
            return false;
        }else {
            return true;
        }
    }

    @Override
    public boolean selectByPhoneAndPwd(AccountInfo accountInfo) {
        List<AccountInfo> aif = accountInfoMapper.selectByPhoneAndPwd(accountInfo);
        System.out.println("aif = " + aif);
        if(aif.size() > 0) {
            return true;
        }else{
            return false;
        }
    }

    @Override
    public int deleteByPrimaryKey(Integer aId) {
        return accountInfoMapper.deleteByPrimaryKey(aId);
    }

    @Override
    public boolean insert(AccountInfo accountInfo) {
        boolean b = accountInfoMapper.insert(accountInfo) > 0;
        return b;
    }

    @Override
    public int insertSelective(AccountInfo record) {
        return accountInfoMapper.insertSelective(record);
    }

    @Override
    public AccountInfo selectByPrimaryKey(Integer aId) {
        return accountInfoMapper.selectByPrimaryKey(aId);
    }

    @Override
    public int updateByPrimaryKeySelective(AccountInfo accountInfo) {
        return accountInfoMapper.updateByPrimaryKeySelective(accountInfo);
    }

    @Override
    public int updateByPrimaryKey(AccountInfo accountInfo) {
        return accountInfoMapper.updateByPrimaryKey(accountInfo);
    }

//    @Override
//    public boolean updatepasswordByphone(AccountInfo accountInfo) {
//        accountInfoMapper.updatepasswordByPhone(phone)>0;
//    }

}
